package com.arvato.minipro.service.mall;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.arvato.minipro.bean.bean_do.mall.EcStoreDo;
import com.arvato.minipro.bean.bean_dto.common.PageData;
import com.arvato.minipro.bean.bean_dto.common.Query;
import com.arvato.minipro.bean.bean_vo.mall.EcStoreVo;
import com.arvato.minipro.mapper.mall.EcStoreMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

/**
 * 
 * @author: smallking
 * 
 * @Descibe:门店管理service
 * 
 * @Date: 2018年6月13日  下午6:45:12
 */
@Service
@Transactional
public class StoreService {
	@Autowired
	private EcStoreMapper storeMapper;
	
	/**
	 * 根据Query查询用户订单列表
	 * @param query
	 * @return
	 */
	public PageData listStoreByQuery(Query query) {
		// 设置分页参数
		PageHelper.startPage(query.getPageNum(), query.getPageSize());
		// 执行查询
		List<EcStoreVo> userList = storeMapper.listStoreByQuery(query);
		// 得到结果
		PageInfo<EcStoreVo> pageInfo = new PageInfo<EcStoreVo>(userList);
		List<EcStoreVo> list = pageInfo.getList();
		PageData data = new PageData(pageInfo.getTotal(), list);
		return data;
	}
	/**
	 * 查询一个门店的详情
	 * @param storeId
	 * @return
	 */
	public EcStoreVo getStoreById(String storeId) {
		return storeMapper.getStoreById(storeId);
	}

	/**
	 * 新增门店
	 * @param StoreDo
	 * @param commodityInfoStr
	 * @return
	 */
	public int insert(EcStoreDo store) {
		int row = storeMapper.insert(store);
		return row;
	}
	
	/**
	 * 修改门店
	 * @param StoreDo
	 * @param commodityInfoStr
	 * @return
	 */
	public int update(EcStoreDo storeDo) {
		int row = storeMapper.update(storeDo);
		return row;
	}
	
	/**
	 * 删除门店
	 * @param StoreDo
	 * @param commodityInfoStr
	 * @return
	 */
	public int delete(String storeId) {
		int row = storeMapper.delete(storeId);
		return row;
	}
	
	
}
